package com.idna.batchid.batch.job;

import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.springframework.batch.item.ItemWriter;

import com.idna.batchid.domain.Record;


public class XmlWriter implements ItemWriter<Record>
{

	@Override
	public void write(List<? extends Record> items) throws Exception
	{
		String output = null;
		
		for(Record record:items)
		{
			Map<String,String> map = record.getRecord();
			
			for(Entry<String,String> entry:map.entrySet())
			{
				output += String.format("<%s>%s</%s>", entry.getKey(), entry.getValue(), entry.getKey());
			}
		}
		
		System.out.println(String.format("<record>%s</record>", output));
	}

}
